window.addEventListener('load', function () {
    var regtel = /^1[3|4|5|7|8]\d{9}$/;
    var regyzm = /^\d{5}$/;
    var regpwd = /^[a-z0-9]{6,12}$/
    var tel = document.querySelector('.tel');
    var yzm = document.querySelector('.yzm');
    var pwd = document.querySelector('.pwd');
    var surepwd = document.querySelector('.surepwd');
    regExp(tel, regtel);
    regExp(yzm, regyzm);
    regExp(pwd, regpwd);
    function regExp(ele, reg) {
        ele.onblur = function () {
            if (reg.test(this.value)) {
                this.nextElementSibling.className = 'correct';
                this.nextElementSibling.innerHTML = '<i class="correct_icon"></i> 恭喜您输入正确';
            } else {
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式输入错误，请重新输入';
            }
        }
    }

    surepwd.onblur = function () {
        if (this.value == pwd.value) {
            this.nextElementSibling.className = 'correct';
            this.nextElementSibling.innerHTML = '<i class="correct_icon"></i> 密码确认成功';
        } else {
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 密码确认失败,请重新输入';
            this.value = '';
        }
    }
})